﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Smart
{
    public class ExceptionHandling
    {
        public static void Hand(Exception ex)
        {
            string file = Path.Combine(Methods.StartupPath(), "hata.txt");
            using (StreamWriter sw = new StreamWriter(file, true))
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("Tarih:" + DateTime.Now.ToShortDateString() + "\r\n");
                sb.Append("Saat:" + DateTime.Now.ToShortTimeString() + "\r\n");
                sb.Append("Hata Mesajı:" + ex.Message + "\r\n");
                if (ex.InnerException != null)
                {
                    sb.Append("Inner Exception:" + ex.InnerException.Message + "\r\n");
                }
                sb.Append("Stack:" + ex.StackTrace);
                sw.WriteLine(sb.ToString());
                sw.Close();
            }
        }
    }
}
